<%@ page import="com.bjpowernode.user.Order" %>
<%@ page import="java.util.List" %>
<%@ page import="java.text.SimpleDateFormat" %><%--
  Created by IntelliJ IDEA.
  User: 16219
  Date: 2022/5/3
  Time: 9:37
  To change this template use File | Settings | File Templates.
--%>
<%
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" +
            request.getServerPort() + request.getContextPath() + "/";
%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <base href="<%=basePath%>">
    <%
        String username = (String) session.getAttribute("username");
        List<Order> orderList = (List<Order>) request.getAttribute("takeOrder");
    %>
    <style type="text/css">
        *{
            margin: 0;
            padding: 0;
        }
        #left ul li{
            list-style: none;
        }
        a{
            text-decoration: none;
            color: white;
        }
        .dynamic{
            width: 850px;
            height: auto;
            margin-top: 10px;
            background: white;
        }
        .shang{
            height: 20px;
            width: 850px;
        }
        .name{
            margin-left: 30px;
            height: 30px;
            width: 790px;
        }
        .time{
            margin-top: 3px;
            margin-left: 30px;
            height: 20px;
            width: 790px;
        }
        .neirong{
            margin-top: 30px;
            margin-left: 30px;
            width: 790px;
            height: 200px;
        }
        .img{
            width: 150px;
            height: 150px;
            float: left;
        }
        .imgRight{
            margin-left: 20px;
            width: 500px;
            height: 150px;
            float: left;
        }
        .foodName{
            margin-left: 20px;
            margin-top: 10px;
        }
        .btn{
            color: white;
            outline: none;
            border: 0;
            background-color: rgb(255,129,64);
            width: 100px;
            height: 40px;
            margin-right: 10px;
            margin-top: 8px;
            font-size: 16px;
            border-radius: 5px;
            cursor: pointer;
        }
    </style>
    <script type="text/javascript" src="jQuery/jquery-3.5.1.js"></script>
    <script type="text/javascript">
        function overOrder(index){
            $.ajax({
                url:"order/modifyOrder.do",
                data:{
                    id:index
                },
                success:function(response){
                    alert("订单已完成");
                    document.getElementById("formOne").submit();
                },
                error:function (response){
                    alert("系统繁忙");
                }
            })
        }
    </script>
</head>
<body>
<form action="order/loadUserTakeOrder.do?name=<%=username%>" method="post" id="formOne"></form>
<%
    if (orderList.isEmpty()) {
%>
<center>
    <div style="background: white;width: 850px;height: 50px;line-height: 50px;margin-top: 10px">
        这里空空如也，您还没有接过任何订单。。。
    </div>
</center>
<%
    } else {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        for (int i = 0; i < orderList.size(); i++) {
            Order order = orderList.get(i);
%>
<center id="one">
    <div class="dynamic">
        <div class="shang">
        </div>
        <div class="name" align="left">
            <b><%=order.getFoodName()%></b>
        </div>
        <div class="time" align="left" style="color: #909090;font-size: 15px">
            <%=sdf.format(order.getCreateTime())%>
        </div>
        <div class="neirong" align="left">
            <div class="img" align="left">
                <img src="<%=order.getFoodPicture()%>" style="height: 150px; width: 150px"/>
            </div>
            <div class="imgRight" align="left">
                <div class="foodName" style="margin-top: -2px">
                    <b>店铺地址:</b><%=order.getProvideAddress()%>
                </div>
                <div class="foodName">
                    <b>用户姓名:</b><%=order.getUserName()%>
                </div>
                <div class="foodName">
                    <b>用户手机:</b><%=order.getUserPhone()%>
                </div>
                <div class="foodName">
                    <b>用户地址:</b><%=order.getUserAddress()%>
                </div>
                <%
                    if (order.getIsDelivery() == 0) {
                %>
                <div class="foodName">
                    <input type="button" value="订单已送达" class="btn" onclick="overOrder(<%=order.getId()%>)"/>
                </div>
                <%
                    } else {
                %>
                <div class="foodName">
                    订单已完成
                </div>
                <%
                    }
                %>
            </div>
        </div>
    </div>
</center>
<%
        }
    }
%>
</body>
</html>
